<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>${fns:getConfig('productName')}</title>
    <meta name="decorator" content="blank"/>
    <style type="text/css">
        html, body, table {
            background-color: #f5f5f5;
            width: 100%;
            height: 100%;
            text-align: center;
        }

        .form-signin-heading {
            font-family: Helvetica, Georgia, Arial, sans-serif, 黑体;
            font-size: 36px;
            margin-bottom: 20px;
            color: #0663a2;
        }

        .form-signin {
            position: relative;
            text-align: left;
            width: 400px;
            padding: 25px 29px 29px;
            margin: 0 auto 20px;
            background-color: rgba(0,0,50,0.3);
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
            -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
            box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
        }

        .header {
            height: 80px;
            padding-top: 20px;
        }

        .alert {
            position: relative;
            width: 300px;
            margin: 0 auto;
            *padding-bottom: 0px;
        }

        label.error {
            background: none;
            width: 270px;
            font-weight: normal;
            color: inherit;
            margin: 0;
        }
        .control-group {
            border-bottom: none;
        }
        body {
            background: url(${ctxStatic}/images/login_bg.png) no-repeat center center;
            background-size:100% ;
        }
        .control-label{
            color: white;
            line-height: 30px;
            font-size: 15px;
        }
    </style>
</head>
<body>
<div class="header">
    <div id="messageBox" class="alert alert-error ${empty message ? 'hide' : ''}">
        <button data-dismiss="alert" class="close">×</button>
        <label id="loginError" class="error">${message}</label>
    </div>
</div>
<h1 class="form-signin-heading">${fns:getConfig('productName')}</h1>
<div class="form-signin">
    <div class="control-group">
        <label class="control-label" style="float: left;">随机码：</label>
        <div class="controls" style="float: left;">
            <span id="licenseId" style="line-height: 30px;color: #000000;font-size: 16px;">${licenseId}</span>
        </div>
    </div>
    <c:if test="${empty licenseId}">
        <div id="license_btn" class="control-group" style="margin-top: 30px;margin-left:120px;width: 120px;">
            <a href="javascript:void(0)" class="btn btn-primary"
               onclick="buildLicenseId()">&nbsp;&nbsp;生成随机码&nbsp;&nbsp;</a>
        </div>
    </c:if>
        <div id="re_license_btn" class="control-group" style="margin-top: 30px;margin-left:120px;width: 150px;display: ${not empty licenseId?"block":"none"}">
            <a href="javascript:void(0)" class="btn btn-primary"
               onclick="reBuildLicenseId()">&nbsp;&nbsp;重新生成随机码&nbsp;&nbsp;</a>
        </div>

    <form:form id="uploadLicenseForm" action="${ctx}/license/checkLicense" method="post" cssStyle="margin-top: 30px;width: 400px;height: 100px;"
               enctype="multipart/form-data">
        <div class="control-group">
            <label class="control-label" style="float: left;">选择授权文件：</label>
            <div class="controls" style="float: left;">
                <input name="mfile" type="file" class="control-label"/>
            </div>
        </div>
        <div style="width: 100px;" class="control-group">
            <a href="javascript:void(0)" class="btn btn-primary" style="margin-left:120px;width: 120px;margin-top: 20px;"
               onclick="uploadLicenseForm()">&nbsp;&nbsp;授权&nbsp;&nbsp;</a>
        </div>
    </form:form>
</div>

<div class="footer">
</div>
<script type="text/javascript">
    function uploadLicenseForm() {
        $("#uploadLicenseForm").submit();
    }
    function buildLicenseId() {
        $.ajax({
            type: "POST",
            url: "${ctx}/license/buildLicenseId",
            dataType: "text",
            success: function (data) {
                if(data != "") {
                    $("#licenseId").html(data);
                    $("#license_btn").remove();
                    $("#re_license_btn").show();
                }
            }
        });
    }
    function reBuildLicenseId() {
        $.ajax({
            type: "POST",
            url: "${ctx}/license/reBuildLicenseId",
            dataType: "text",
            success: function (data) {
                if(data != "") {
                    $("#licenseId").html(data);
                    $("#license_btn").remove();
                }
            }
        });
    }
</script>
</body>
</html>